import { request } from '@/service/request';

/** 获取微信支付配置列表 */
export function fetchGetWechatPayConfigList(params?: Api.Business.WechatPayConfigSearchParams) {
  return request<Api.Business.WechatPayConfigList>({
    url: '/wechat_pay_config/getAll',
    method: 'post',
    data: params
  });
}

/** 新增微信支付配置 */
export function fetchCreateWechatPayConfig(data: Api.Business.WechatPayConfigOperateParams) {
  return request<boolean>({
    url: '/wechat_pay_config/add',
    method: 'post',
    headers: {
      isEncrypt: true,
      repeatSubmit: false
    },
    data
  });
}

/** 修改微信支付配置 */
export function fetchUpdateWechatPayConfig(data: Api.Business.WechatPayConfigOperateParams) {
  return request<boolean>({
    url: '/wechat_pay_config/update',
    method: 'post',
    data
  });
}

/** 上传文件 */
export function uploadFile(file: File) {
  // 创建FormData对象，用于文件上传
  const formData = new FormData();
  formData.append('file', file);

  return request<Api.Business.FileVO>({
    url: '/common/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data' // 设置正确的Content-Type
    }
  });
}
